package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.DeliverProducts;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class DeliverProductsVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "产品id")
    private Integer quotesProductId;

    @ApiModelProperty(value = "送货id")
    private Integer deliverId;

    @ApiModelProperty(value = "合同数量")
    private Integer num;

    @ApiModelProperty(value = "已发货数量")
    private Integer deliverNum;

    @ApiModelProperty(value = "本次发货数量")
    private Integer oneNum;

    @ApiModelProperty(value = "产品id")
    private Integer productId;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static DeliverProducts convert(DeliverProductsVO vo) {
        DeliverProducts entity = new DeliverProducts();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<DeliverProducts> convertList(List<DeliverProductsVO> list) {
        List<DeliverProducts> resultList = new ArrayList<>();
        for (DeliverProductsVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
